class MinigameTrigger extends UseTrigger;

var() int MinigameNumber;
var EffectGlowPulse TheGlow;

simulated function PostBeginPlay() {

    super.PostBeginPlay();
    TheGlow = Spawn(class'Enyara.EffectGlowPulse',,,Location);

}

function bool SelfTriggered()
{
	return true;
}

function UsedBy( Pawn user )
{
	TriggerEvent(event, self, user);
}

function Touch( Actor Other )
{
    local EnyaraPlayerController PC;
    local MinigamePlayerStart PS;
    local MinigamePlayerController MGPC;
    local MinigamePawn MGPawn;

    PC = EnyaraPlayerController(level.GetLocalPlayerController());
    //PC.ClientMessage(PC@Other);

    if (PC.Pawn == Other) {
    foreach AllActors (class'MinigamePlayerStart', PS) {
        if (PS.MinigameNumber == MinigameNumber) {
            PC.ClientMessage (PS.Location);
            //PC.Pawn.SetLocation (PS.Location);
            // classname, owner, tag, location, rotation
            MGPawn = Spawn(class'MinigamePawn', PC, , PS.Location);
            if (PC.bMinigameMode==false) {
                PC.PreMinigameEnyaraPawn = EnyaraPawn(PC.Pawn);
                PC.bMinigameMode=true;
                self.Destroy();
                TheGlow.Kill();
            }
            PC.InputClass = class'MinigamePlayerInput';
            PC.CurrentMinigamePlayerStart=PS;
            PC.UnPossess();
            PC.Possess(MGPawn);
        }
    }
    }

}

defaultproperties {
    MinigameNumber=1
    bHidden=true
}
